package com.mop.sg2.map;

import org.apache.mina.core.buffer.IoBuffer;

public class LoginMsg {

	String name = null;

	String password = null;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void init(IoBuffer buffer) {
		System.out.println("========Receive");
		
		// 读取String
		buffer.flip();
		int id = buffer.getShort();
		System.out.println("Message Id:" + id);

		int length = buffer.getShort();
		IoBuffer tmp = IoBuffer.allocate(length);
		tmp.put(buffer.getSlice(length));
		name = new String(tmp.array());
		System.out.println("name:" + name);

		length = buffer.getShort();
		tmp = IoBuffer.allocate(length);
		tmp.put(buffer.getSlice(length));
		password = new String(tmp.array());
		System.out.println("password:" + password);
		
		
		
		// if (session != null) {
		// MessageExample e = new MessageExample();
		// e.setName("Jay 黄 Server" + index);
		// e.setYear(2011 + index);
		// e.setSex((short) index);
		// e.setM(2.1314 + index);
		// index++;
		// session.write(e);
		// }
	}

}
